<?php

Yii::import('application.models._base.BaseFavoriteAlbum');

class FavoriteAlbum extends BaseFavoriteAlbum
{
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}

    public function getFavoriteAlbum($album_id,$my_id,$first,$total){
        $db = Yii::app()->db->createCommand();
        $db->select('u.id,u.nick_name,u.avatar_public,u.avatar_status,u.bg,u.domain');
        $db->from('{{favorite_album}} fa');
        $db->join('{{user}} u','u.id=fa.user_id');
        $db->where('fa.album_id=:album_id and u.status=:status',array(':album_id'=>$album_id,':status'=>1));
        $db->order('fa.create_time desc');
        $db->limit($total,$first);
        $info = $db->queryAll();
        if($info){
            foreach($info as $k=>$v){
                //获取粉丝最新的3个图片
                $info[$k]['images'] = Share::model()->getThreeShare($v['id']);
                //获取  我  与 他的粉丝的关系
                if($my_id){
                    $info[$k]['relationship'] = Relationship::model()->getRelationship($v['id'],$my_id);
                }else{
                    $info[$k]['relationship'] = false;
                }
            }
        }
        return $info;
    }


}